package nautilus.service;

import java.util.ArrayList;
import java.util.List;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class DataReceiver extends BroadcastReceiver{

	private List<IMessageHandler> _handlers = null;
	
	public DataReceiver(){
		_handlers = new ArrayList<IMessageHandler>();
	}
	
	public void addHandler(IMessageHandler hl){
		_handlers.add(hl);
	}
	
	public void removeHandler(IMessageHandler hl){
		_handlers.remove(hl);
	}
	
	@Override
	public void onReceive(Context ctx, Intent intent) {
		
		if (intent.getAction().equals("NAUTILUS_DATA_COMMUNICATION")) {
			
			for(IMessageHandler handler: _handlers)
				handler.onDataReceived(intent);
		}
		
	}

}
